package com.prs.crm.job.impl;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.log4j.Logger;
import org.courser.Util;
import org.springframework.beans.factory.annotation.Autowired;

import com.prs.crm.job.OnlineListener;

import com.prs.crm.service.exchange.OnlinePersonService;

public class OnlineListenerImpl implements OnlineListener {

	private static final Logger log = Logger
			.getLogger(OnlineListenerImpl.class);

	@Autowired
	private OnlinePersonService onlinePersonService;
	

	public void setOnlinePersonService(OnlinePersonService onlinePersonService) {
		this.onlinePersonService = onlinePersonService;
	}

	public OnlinePersonService getOnlinePersonService() {
		return onlinePersonService;
	}

	

	// 每隔3分钟执行一次

	public void execute() {
		try {
			Date time = Util.nowFullTime();
			this.getOnlinePersonService().removeOverTime(
					Util.addTimeByMinutes(time, -5));
		} catch (Exception e) {

			log.error(e);
		}
	}

}
